
package cn.gz3c.uitest.view;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;

import com.huawei.hms.audioeditor.sdk.effect.HAEEffect;
import com.huawei.hms.audioeditor.sdk.effect.HAEEffect.HAEEffectType;
import com.huawei.hms.audioeditor.sdk.util.SmartLog;
import com.huawei.hms.audioeditor.ui.R.color;

import cn.gz3c.uitest.viewmodel.EditPreviewViewModel;
import cn.gz3c.uitest.Util;

@SuppressLint("ViewConstructor")
public class SpecialTrackView extends BaseTrackView {
    private HAEEffectType haeEffectType;
    private String J;

    public SpecialTrackView(Activity var1, EditPreviewViewModel var2) {
        super(var1, var2);
    }

    protected void onMeasure(int var1, int var2) {
        super.onMeasure(var1, var2);
        this.b(Util.dip2px(30.0F));
    }

    @SuppressLint({"DrawAllocation"})
    protected void onDraw(Canvas var1) {
        Paint var2;
        var2 = new Paint();
        int var3 = -65536;
        HAEEffectType var4;
        if ((var4 = this.haeEffectType) != null) {
            int ordinal = var4.ordinal();
            if (ordinal == HAEEffectType.EQUALIZER.ordinal()) {
                var3 = this.getResources().getColor(color.bg_equilibrium);
            } else if (ordinal == HAEEffectType.SOUND_FIELD.ordinal()) {
                var3 = this.getResources().getColor(color.bg_sound);
            } else if (ordinal == HAEEffectType.STYLE.ordinal()) {
                var3 = this.getResources().getColor(color.bg_style);
            } else if (ordinal == HAEEffectType.SOUND_TYPE.ordinal()) {
                var3 = this.getResources().getColor(color.bg_voice_change);
            } else if (ordinal == HAEEffectType.REDUCE_NOISE.ordinal()) {
                var3 = this.getResources().getColor(color.bg_reduce_noise);
            } else if (ordinal == HAEEffectType.ENVIRONMENT.ordinal()) {
                var3 = this.getResources().getColor(color.bg_environment);
            } else {
                var3 = this.getResources().getColor(color.import_button_search);
            }
        }

        var2.setColor(var3);
        var2.setAntiAlias(true);
        RectF var8;

        float var10002 = (float) (this.m() + super.a);
        float var10003 = (float) Util.dip2px(1.0F);
        double var6 = (double) (this.m() + super.a);
        var8 = new RectF(var10002, var10003, (float) (this.j() + var6), (float)Util.dip2px(30.0F));
        float var7;
        if (this.o().equals(super.editPreviewViewModel.getLdUuid().getValue())) {
            var7 = 0.0F;
        } else {
            var7 = (float) Util.dip2px(4.0F);
        }

        float var5;
        if (this.o().equals(super.editPreviewViewModel.getLdUuid().getValue())) {
            var5 = 0.0F;
        } else {
            var5 = (float) Util.dip2px(4.0F);
        }

        var1.drawRoundRect(var8, var7, var5, var2);
        if (this.J != null) {
            Paint var10000 = var2 = new Paint();
            var10000.setTextSize((float) Util.dip2px(10.0F));
            var10000.setAntiAlias(true);
            var10000.setColor(-1);
            if (Util.isRTL()) {
                var2.setTextScaleX(-1.0F);
            } else {
                var2.setTextScaleX(1.0F);
            }

            String var9;
            if (Util.isRTL()) {
                var9 = this.J;
                int var10004 = this.m() + super.a;
                var3 = Util.dip2px(10.0F) + var10004;
                var1.drawText(var9, (float) (this.a(this.J, var2) + var3), (float)Util.dip2px(20.0F), var2);
            } else {
                var9 = this.J;
                int var10 = this.m() + super.a;
                var1.drawText(var9, (float) (Util.dip2px(10.0F) + var10), (float) Util.dip2px(20.0F), var2);
            }
        }

        super.onDraw(var1);
    }

    void a(long var1, int var3) {
        StringBuilder var10000 = new StringBuilder();
        SmartLog.i("handleCutEvent", var10000.append(var1).append("").toString());
    }

    public void b(HAEEffect haeEffect) {
        this.haeEffectType = haeEffect.getEffectType();
        this.J = haeEffect.getOptions().getEffectPath();
        this.a(haeEffect);
        super.startTime = haeEffect.getStartTime();
        super.r = haeEffect.getEndTime() - haeEffect.getStartTime();
        this.c(300.0D);
        this.s();
        this.post(this::invalidate);
        this.setOnClickListener((var2) -> {
            if (haeEffect.getUuid().equals(super.editPreviewViewModel.getLdUuid().getValue())) {
                SpecialTrackView var10000 = this;
                EditPreviewViewModel var3 = super.editPreviewViewModel;
                byte var4;
                if (var10000.haeEffectType == HAEEffectType.REDUCE_NOISE) {
                    var4 = 3;
                } else {
                    var4 = 2;
                }

                var3.b(var4);
            }

        });
    }
}
